<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>网络监控工具</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <link href="./styles.css" rel="stylesheet">
</head>
<body class="light-theme">
    <div class="container-fluid">
        <!-- 控制面板 -->
        <div class="card mb-4 shadow-sm">
            <div class="card-header bg-secondary text-white">
                <h5 class="mb-0"><i class="fas fa-cog me-2"></i>监控设置</h5>
            </div>
            <div class="card-body">
                <div class="d-flex justify-content-between align-items-center flex-wrap gap-3">
                    <div class="d-flex flex-wrap gap-3">
                        <div class="d-flex align-items-center">
                            <label for="intervalInput" class="form-label me-2 mb-0">定时间隔（秒）:</label>
                            <input type="number" id="intervalInput" class="form-control" value="5" style="width: 100px;">
                        </div>
                        <div class="d-flex align-items-center">
                            <label for="threadsInput" class="form-label me-2 mb-0">最大线程数:</label>
                            <input type="number" id="threadsInput" class="form-control" value="20" style="width: 100px;">
                        </div>
                        <button id="updateBtn" class="btn btn-primary">
                            <i class="fas fa-sync me-2"></i>更新参数
                        </button>
                    </div>
                    <div class="d-flex align-items-center">
                        <span class="me-2">运行状态:</span>
                        <span id="statusLabel" class="badge bg-success">运行中</span>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 操作按钮 -->
        <div class="card mb-4 shadow-sm">
            <div class="card-body">
                <div class="d-flex justify-content-between flex-wrap gap-2">
                    <div class="d-flex flex-wrap gap-2">
                        <button id="addBtn" class="btn btn-success">
                            <i class="fas fa-plus me-1"></i>新增
                        </button>
                        <button id="startBtn" class="btn btn-primary">
                            <i class="fas fa-play me-1"></i>开启
                        </button>
                        <button id="stopBtn" class="btn btn-warning">
                            <i class="fas fa-pause me-1"></i>暂停
                        </button>
                        <button id="deleteBtn" class="btn btn-danger">
                            <i class="fas fa-trash me-1"></i>删除
                        </button>
                        <button id="executeNowBtn" class="btn btn-info">
                            <i class="fas fa-bolt me-1"></i>立即执行
                        </button>
                    </div>
                    <div class="d-flex align-items-center">
                        <div class="theme-switcher">
                            <button id="lightThemeBtn" class="btn btn-light btn-sm"><i class="fas fa-sun"></i> 明亮</button>
                            <button id="darkThemeBtn" class="btn btn-dark btn-sm ms-2"><i class="fas fa-moon"></i> 暗黑</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 监控表格 -->
        <div class="card shadow-sm">
            <div class="card-header bg-secondary text-white">
                <h5 class="mb-0"><i class="fas fa-table me-2"></i>监控目标</h5>
            </div>
            <div class="card-body p-0">
                <div class="table-container">
                    <table id="monitorTable" class="table table-striped table-hover mb-0">
                        <thead class="table-dark">
                            <tr>
                                <th><input type="checkbox" id="selectAll"></th>
                                <th>ID</th>
                                <th>描述</th>
                                <th>IP地址</th>
                                <th>端口</th>
                                <th>状态</th>
                                <th>成功率</th>
                                <th>成功次数</th>
                                <th>失败次数</th>
                                <th>上一次执行时间</th>
                                <th>最新检测结果</th>
                                <th>检测方式</th>
                            </tr>
                        </thead>
                        <tbody id="tableBody">
                            <!-- 表格内容将通过JavaScript动态填充 -->
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <!-- 消息通知区域 -->
    <div id="messageNotification" class="notification" style="display: none;"></div>
    
    <!-- 新增监控项模态框 -->
    <div class="modal fade" id="addItemModal" tabindex="-1" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">新增监控项</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <form id="addItemForm">
                        <div class="mb-3">
                            <label for="itemDesc" class="form-label">描述</label>
                            <input type="text" class="form-control" id="itemDesc" required>
                        </div>
                        <div class="mb-3">
                            <label for="itemIP" class="form-label">IP地址</label>
                            <input type="text" class="form-control" id="itemIP" required>
                        </div>
                        <div class="mb-3">
                            <label for="itemPort" class="form-label">端口（可选）</label>
                            <input type="text" class="form-control" id="itemPort">
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" id="saveItemBtn">保存</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 脚本 -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="./app.js"></script>
</body>
</html>